home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / clipper / ks94an.zip / SNATCH.HDR < prev    next >
Text File  |  1994-04-25  |  2KB  |  56 lines

  1. /******************************************************************************
  2.                  The Klipper Library, for CA-Clipper 5.x
  3.         Copyright (c), 1994, Wallace Information Systems Engineering
  4.  
  5. FUNCTION:
  6.  
  7. _Snatch( cInStr, nLowBound, nHighBound ) --> cString
  8.  
  9. PARAMETERS:
  10.  
  11. cInStr     : string to extract from
  12. nLowBound  : Low position number
  13. nHighBound : high position number
  14.  
  15. SHORT:
  16.  
  17. A modified SUBSTR() with absolute from/to params rather than from/len.
  18.  
  19. DESCRIPTION:
  20.  
  21. _Snatch() returns a string between two positions rather than between a
  22. start/offset (as with substr()).
  23.  
  24. It is a useful alternative to substr() where you must supply a start position
  25. and a number of characters.  When you are not sure where the substr is or how
  26. long it is, you can use _Snatch() in conjunction with _nth_occr(), at(),
  27. etc, to get the substr even when you do not know it's exact placement within
  28. the string.
  29.  
  30. NOTE:
  31.  
  32.  
  33.  
  34. EXAMPLE:
  35.  
  36. t = _snatch('ABCDEFGHIJ',5,10)
  37. Result: t = 'EFGHIJ'
  38.  
  39. When the exact placement of the string is unknown, but a set of
  40. delimiting characters IS known:
  41.  
  42. string1 = 'Dear <FNAME>, Howdy!'
  43. string2 = 'Greetings <FULLNAME>'
  44.  
  45. t1 = _Snatch(string1,at('<',string1)+1,at('>',string1)-1)
  46. t2 = _Snatch(string2,at('<',string1)+1,at('>',string1)-1)
  47.  
  48. Result: t1 = "FNAME"
  49. t2 = "FULLNAME"
  50.  
  51. Note that in this example, the same _Snatch() syntax extracts the text
  52. delimited by <> even though the desired texts were of different lengths and
  53. began at different positions.
  54.  
  55. ******************************************************************************/
  56.